package com.onlinefurnitureshop.category.controller;

import java.util.List;

import com.onlinefurnitureshop.category.model.Category;
import com.onlinefurnitureshop.category.service.FurnitureTypeService;

public class CategoryAction {
	
	
	private FurnitureTypeService furnitureTypeService;
	private List<Category> categoryList;
	private Category category;
	private int id;
	private int pid;

	
	
	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	
	
	
	public int getPid() {
		return pid;
	}

	public void setPid(int pid) {
		this.pid = pid;
	}

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public List<Category> getCategoryList() {
		return categoryList;
	}

	public void setCategoryList(List<Category> categoryList) {
		this.categoryList = categoryList;
	}

	public FurnitureTypeService getFurnitureTypeService() {
		return furnitureTypeService;
	}

	public void setFurnitureTypeService(FurnitureTypeService furnitureTypeService) {
		this.furnitureTypeService = furnitureTypeService;
	}
	
	

	public String list(){
		categoryList = furnitureTypeService.findAll();
		return "categoryList";
	}
	
	public String showCreateForm(){
		System.out.println(id);
		id = 0;
		category = new Category();
		return "categoryEdit";
	}
	
	public String create(){
		System.out.println(id);
		furnitureTypeService.save(category);
		return "listAction";
	}
	
	public String showDeleteForm(){
		System.out.println("deleteForm:"+id);
		return "categoryDelete";
	}
	
	public String delete(){
		System.out.println("delete:"+id);
		furnitureTypeService.delete(id);
		return "listAction";
	}
	public String showUpdateForm(){
		System.out.println("updateForm:"+id);
		category = furnitureTypeService.getTypeById(id);
		return "categoryEdit";
	}
	public String update(){
		System.out.println("update:"+id);
		furnitureTypeService.update(category);
		return "listAction";
	}
	
}
